package com.noyes4j.common.utils.airkiss;

import java.io.UnsupportedEncodingException;
import java.util.Base64;

/**
* @Description:    Base64编码/解码
* @Author:         luoyhong
* @CreateDate:     2021/1/28 17:56
* @UpdateUser:     luoyhong
* @UpdateDate:     2021/1/28 17:56
* @UpdateRemark:   修改内容
* @Version:        1.0
*/
public class Base64Util {

    public static String encode(String content){
        String encoderStr = "";
        Base64.Encoder encoder = Base64.getEncoder();
        try {
            encoderStr = encoder.encodeToString(content.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return encoderStr;
    }
    public static String decode(String content){

        String decoderStr = "";
        Base64.Decoder decoder = Base64.getDecoder();
        try {
            decoderStr = new String(decoder.decode(content), "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return decoderStr;
    }
}
